﻿// JScript 文件
var m_xmin = 0, m_ymin = 0, m_xmax = 0, m_ymax = 0;
var m_oldxmin = 0, m_oldymin = 0, m_oldxmax = 0, m_oldymax = 0;
var m_Height = 0, m_Width = 0, m_pixelX = 0, m_pixelY = 0;
var m_widx = 0, m_widy = 0;
var m_ActieTool=0;
var m_MouseDown = new MouseDot(0,0)
var m_MouseUp = new MouseDot(0,0)
var aTree;
var m_DldIDList = new Array();
var m_DldBZList = new Array();
var m_GldIDList = new Array();
var m_GldBZList = new Array();
var xmlHttp;
var m_pntMajor, m_pntMinor, m_pntID
var vstrTreeXml;
//存放上次画的ＩＤ
var ArrayRemoveByID = new Array();
//全局树的ID主要是为了Xwin的id是funPage+divlxTree
var flagRight = true;
var vCount = 0;
var m_fs = 4;    //管孔编码初始字体大小
var m_h = 1.2;   //节点展开图放大、缩小倍数
var m_ovalList = new Array();

var m_bodyWidth = 0;
var m_bodyHeight = 0;

//鼠标坐标结构体
function MouseDot(x, y)
{
   this.x = x;                 //鼠标X坐标
   this.y = y;                 //鼠标Y坐标
}

//管孔信息结构体
function ovalItem(id,useInfo)
{ 
    this.id      = id;          //管孔ID
    this.useInfo = useInfo;     //管孔占用信息
}

//缆线信息结构体
function cableItem(typeID1,typeID2,type,major,minor)
{
    this.typeID1     = typeID1;
    this.typeID2     = typeID2;
    this.type        = type;
    this.major       = major;
    this.minor       = minor;
}

var m_IsJwd;
function init()
{
    m_pntMajor = $("MjValue").value;
    m_pntMinor = $("MnValue").value;
    m_pntID    = $("PntID").value;
    
    var url = "/handlers/MapHandler.ashx?";
    var mapCfg   = CtnTrans.getXml(url, "POST", "method=getCfg");
    var m = mapCfg.selectSingleNode("m");
    m_IsJwd    = parseInt(m.getAttribute("isjwd")) == 1 ? true : false;
    
    
    this.ToolBar();     //绘制工具条
    createTopDiv();     //创建窗口操作DIV（最顶层DIV）
    window.RectPen.Container = $("allInfoDiv"); //设置矩形画笔绘画容器
    
    initpntdispxml(m_pntMajor,m_pntMinor,m_pntID);
}

//创建窗口操作DIV
function createTopDiv()
{
    var $body = window.document.getElementsByTagName("body")[0];
    redrawDiv();
    var allInfoDiv=document.createElement("DIV");
	allInfoDiv.id="allInfoDiv";
	allInfoDiv.style.position="absolute";
	allInfoDiv.style.zIndex="8000";
	allInfoDiv.style.left = "0px";
	allInfoDiv.style.top  = "0px";
	allInfoDiv.style.width = m_bodyWidth + "px";
	allInfoDiv.style.height = m_bodyHeight + "px";
	allInfoDiv.style.backgroundColor = "white";
	allInfoDiv.style.filter = "alpha(opacity=10)";
	if($body) $body.appendChild(allInfoDiv);
}

function redrawDiv()
{
    var $body = window.document.getElementsByTagName("body")[0];
	if(CtnBrowser.IE)
	{
	    m_bodyWidth  = $body.clientWidth;
	    m_bodyHeight  = document.documentElement.clientHeight;
	}
	else if(CtnBrowser.FF)
	{
	    m_bodyWidth  = document.documentElement.clientWidth;
	    m_bodyHeight  = document.documentElement.clientHeight;
	}
}

//工具条
this.ToolBar = function()
{
    var toolBar = document.createElement("DIV");
    toolBar.id  = "toolBar";
    toolBar.style.display = "block";
    toolBar.style.position = "absolute";
    toolBar.style.zIndex="10000";
    var $body = document.getElementsByTagName("body")[0];
    toolBar.style.left = parseInt($body.clientWidth)- 166 + "px";
    toolBar.style.width = 166 + "px";
    toolBar.style.height = 26 + "px";
    toolBar.style.top  = 0 + "px";
    toolBar.innerHTML = "<img src=\"../images/zoomin_expand.gif\" onmousedown=\"javascript:this.style.width='25px'\" onmouseup=\"javascript:this.style.width='26px'\" style=\"width:26px;left:5px;position:absolute;cursor:hand;\" onclick=\"javascript:zoomInWnd()\" alt=\"放大窗口\"/>" +
                        "<img src=\"../images/zoomout_expand.gif\" onmousedown=\"javascript:this.style.width='25px'\" onmouseup=\"javascript:this.style.width='26px'\" style=\"width:26px;left:31px;position:absolute;cursor:hand;\" onclick=\"javascript:zoomOutWnd()\" alt=\"缩小窗口\"/>" +
                        "<img src=\"../images/move_expand.gif\" onmousedown=\"javascript:this.style.width='25px'\" onmouseup=\"javascript:this.style.width='26px'\" style=\"width:26px;left:57px;position:absolute;cursor:hand;\" onclick=\"javascript:moveWnd()\" alt=\"移动窗口\"/>" +
                        "<img src=\"../images/refresh_expand.gif\"onmousedown=\"javascript:this.style.width='25px'\" onmouseup=\"javascript:this.style.width='26px'\" style=\"width:26px;left:83px;position:absolute;cursor:hand;\" onclick=\"javascript:resetWnd()\" alt=\"复位窗口\"/>" +
                        "<img src=\"../images/code_expand.gif\"onmousedown=\"javascript:this.style.width='25px'\" onmouseup=\"javascript:this.style.width='26px'\" style=\"width:26px;left:109px;position:absolute;cursor:hand;\" onclick=\"javascript:dispCode()\" alt=\"查看编码\"/>" +
                        "<img src=\"../images/lxinfo_expand.gif\" onmousedown=\"javascript:this.style.width='25px'\" onmouseup=\"javascript:this.style.width='26px'\" style=\"width:26px;left:135px;position:absolute;cursor:hand;\" onclick=\"javascript:dispPntLx()\" alt=\"穿缆及附属设施信息\">";
    toolBar.style.backgroundImage = "url(../images/bg_expand.gif)";
    toolBar.style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=70)";
    $body.appendChild(toolBar);
}

//定义节点展开图右键菜单
function onRightClick(evt)
{   
    mc = new CtnMenuCtrl("mc");
    with(mc)
    {
        addEvent("放大窗口", "zoomInWnd()");
        addEvent("缩小窗口", "zoomOutWnd()");
        addEvent("移动窗口", "moveWnd()");
        addEvent("复位窗口", "resetWnd()");
        addEvent("查看编码", "dispCode()");
        addEvent("穿缆及附属设施信息", "dispPntLx()");
    }
    mc.show(evt);
    return false;
}

//窗口放大
function zoomInWnd()
{
    $("allInfoDiv").onmousedown = function(evt)
    { 
        m_MouseDown.x  = event.clientX;
        m_MouseDown.y  = event.clientY;
        window.RectPener.OnMouseDown(); 
    };
    $("allInfoDiv").onmousemove = function(evt)
    { 
        window.RectPener.OnMouseMove(); 
    };
    $("allInfoDiv").onmouseup = function(evt)
    { 
        window.RectPener.OnMouseUp(); 
        m_MouseUp.x  = event.clientX;
        m_MouseUp.y  = event.clientY;
        
        var offstx = m_MouseUp.x - m_MouseDown.x;
        var offsty = m_MouseUp.y - m_MouseDown.y;
        
        if (offstx == 0 && offsty == 0)
        {
            return;
        }
        
        var x = $("group1").coordsize.x;
        var y = $("group1").coordsize.y;
        $("group1").coordsize=x/m_h+","+y/m_h;
     
        $("group1").style.fontSize=m_fs*m_h+"pt";
        m_fs=m_fs*m_h;
        
        var e = evt ? evt : event;
        if(CtnBrowser.IE)
        { 
            if(e.button == 1) //左键
            {
                $("rightdiv").style.visibility = "hidden";
                
                var xy = window.RectPen.GetWindowCenXY();
                window.RectPener.DelGragph();
                var cx = xy[0];                                   
                var cy = xy[1];

                var offsetX = m_bodyWidth/2 - cx;
                var offsetY = m_bodyHeight/2 - cy;
                $("group1").style.left = parseInt($("group1").style.left) + offsetX + "px";
                $("group1").style.top = parseInt($("group1").style.top) + offsetY + "px";
                redrawDiv();
            }
            if(e.button == 2) //右键
            {
                $("rightdiv").style.visibility = "visible";
            }
        }
        if(CtnBrowser.FF)
        {
            if(e.button == 0) //左键
            {
                $("rightdiv").style.visibility = "hidden";
                
                var xy = window.RectPen.GetWindowCenXY();
                window.RectPener.DelGragph();
                var cx = xy[0];                                   
                var cy = xy[1];

                var offsetX = m_bodyWidth/2 - cx;
                var offsetY = m_bodyHeight/2 - cy;
                $("group1").style.left = parseInt($("group1").style.left) + offsetX + "px";
                $("group1").style.top = parseInt($("group1").style.top) + offsetY + "px";
                redrawDiv();
            }
            if(e.button == 2) //右键
            {
                $("rightdiv").style.visibility = "visible";
            }
        }   
    };
}

//窗口缩小
function zoomOutWnd()
{
    $("allInfoDiv").onmousedown = function(evt)
    { 
        m_MouseDown.x  = event.clientX;
        m_MouseDown.y  = event.clientY;
        window.RectPener.OnMouseDown(); 
    };
    $("allInfoDiv").onmousemove = function(evt)
    { 
        window.RectPener.OnMouseMove(); 
    };
    $("allInfoDiv").onmouseup = function(evt)
    { 
        window.RectPener.OnMouseUp(); 
        m_MouseUp.x  = event.clientX;
        m_MouseUp.y  = event.clientY;
        
        var offstx = m_MouseUp.x - m_MouseDown.x;
        var offsty = m_MouseUp.y - m_MouseDown.y;
        
        if (offstx == 0 && offsty == 0)
        {
            return;
        }
        
        var x = $("group1").coordsize.x;
        var y = $("group1").coordsize.y;
        if (parseInt(x) >= 900 && parseInt(y) >= 900)
        {
            hideWord();
            top.CtnDlg.msg("窗口已达默认最小尺寸！");
            return;
        }
        $("group1").coordsize=x*m_h+","+y*m_h;
     
        $("group1").style.fontSize=m_fs/m_h+"pt";
        m_fs=m_fs/m_h;
        
        var e = evt ? evt : event;
        if(CtnBrowser.IE)
        { 
            if(e.button == 1) //左键
            {
                $("rightdiv").style.visibility = "hidden";
                
                var xy = window.RectPen.GetWindowCenXY();
                window.RectPener.DelGragph();
                var cx = xy[0];                                   
                var cy = xy[1];

                var offsetX = m_bodyWidth/2 - cx;
                var offsetY = m_bodyHeight/2 - cy;
                $("group1").style.left = parseInt($("group1").style.left) + offsetX + "px";
                $("group1").style.top = parseInt($("group1").style.top) + offsetY + "px";
                redrawDiv();
            }
            if(e.button == 2) //右键
            {
                $("rightdiv").style.visibility = "visible";
            }
        }
        if(CtnBrowser.FF)
        {
            if(e.button == 0) //左键
            {
                $("rightdiv").style.visibility = "hidden";
                
                var xy = window.RectPen.GetWindowCenXY();
                window.RectPener.DelGragph();
                var cx = xy[0];                                   
                var cy = xy[1];

                var offsetX = m_bodyWidth/2 - cx;
                var offsetY = m_bodyHeight/2 - cy;
                $("group1").style.left = parseInt($("group1").style.left) + offsetX + "px";
                $("group1").style.top = parseInt($("group1").style.top) + offsetY + "px";
                redrawDiv();
            }
            if(e.button == 2) //右键
            {
                $("rightdiv").style.visibility = "visible";
            }
        }   
    };
}

//窗口移动
function moveWnd()
{
    $("allInfoDiv").onmousedown = function(evt)
    {
        m_MouseDown.x  = event.clientX;
        m_MouseDown.y  = event.clientY;
    };
    $("allInfoDiv").onmousemove = function(evt){};
    $("allInfoDiv").onmouseup = function(evt)
    { 
        var e = evt ? evt : event;
        if(CtnBrowser.IE)
        { 
            if(e.button == 1) //左键
            {
                $("rightdiv").style.visibility = "hidden";
                m_MouseUp.x  = event.clientX;
                m_MouseUp.y  = event.clientY;
                
                var offstx = m_MouseUp.x - m_MouseDown.x;
                var offsty = m_MouseUp.y - m_MouseDown.y;

                $("group1").style.left = parseInt($("group1").style.left) + offstx + "px";
                $("group1").style.top = parseInt($("group1").style.top) + offsty + "px";
                redrawDiv();
            }
            if(e.button == 2) //右键
            {
                $("rightdiv").style.visibility = "visible";
            }
        }
        if(CtnBrowser.FF)
        {
            if(e.button == 0) //左键
            {
                $("rightdiv").style.visibility = "hidden";
                m_MouseUp.x  = event.clientX;
                m_MouseUp.y  = event.clientY;
                
                var offstx = m_MouseUp.x - m_MouseDown.x;
                var offsty = m_MouseUp.y - m_MouseDown.y;

                $("group1").style.left = parseInt($("group1").style.left) + offstx + "px";
                $("group1").style.top = parseInt($("group1").style.top) + offsty + "px";
                redrawDiv();
            }
            if(e.button == 2) //右键
            {
                $("rightdiv").style.visibility = "visible";
            }
        }   
    };
}

//窗口复位
function resetWnd()
{   
    hideCode();
    $("rightdiv").style.visibility = "hidden";

    $("group1").style.left = 156 + "px";
    $("group1").style.top = 64 + "px";
    $("group1").coordsize = "900,900";
    redrawDiv();       
}

//缆线展示
function dispPntLx()
{
    if ($("rightdiv").style.visibility == "visible")
    {
        $("rightdiv").style.visibility = "hidden";
    }
    $("divPntmap").style.cursor = "default"
    CtnTrans.Ajax("/main.ashx?","post","_method=PntExpand_GetPntLx&PntID=" + m_pntID + "&Major=" + m_pntMajor + "&Minor=" + m_pntMinor, getpntlxfs,null,{loading:true});
}

function SetTitle(PntBM)
{
     $("PntTitle").innerText = "节点展开图(实体编码：" + PntBM[0].text + ")";
}

function initpntdispxml(Major,Minor,m_pntID)
{
    $("divPntmap").innerHTML = ""
    CtnTrans.Ajax("/main.ashx?","post","_method=PntExpand_Init&PntID=" + m_pntID + "&Major=" + Major + "&Minor=" + Minor, initPntDesp,{Major:Major,Minor:Minor},{loading:true});
}

function initPntDesp(response,params)
{
    if (!CtnError.validate(response.responseText))
    {
        $("PntTitle").hide();
        CtnError.show();
        return;
    }
    $("PntTitle").show();
    initpntdisp(response.responseText);
}

function dispCode()
{
    if (m_PntNo == 0)
    {
        top.CtnDlg.warning("尚未录入任何管孔信息！");
        return;
    }
    if (m_ovalList.length != 0)
    {
        $("group1").style.left = 156 + "px";
        $("group1").style.top = 64 + "px";
        $("group1").coordsize="362,362";
        $("group1").style.fontSize="9.95328pt";
        m_fs = 9.95328;
        
        for (var i = 0; i < m_ovalList.length; i ++)
        {
            var tempStr = m_ovalList[i].id;
            var idStr = "spanGk1" + tempStr;
            $(idStr).style.zIndex = 10000;
            $(idStr).style.visibility = "visible";
        }
    }
}

//初始人手井,管道匝,地下进线室
function hideCode()
{
    if (m_ovalList.length != 0)
    {
        $("group1").coordsize="362,362";
        $("group1").style.fontSize="9.95328pt";
        m_fs = 9.95328;
        
        for (var i = 0; i < m_ovalList.length; i ++)
        {
            var tempStr = m_ovalList[i].id;
            var idStr = "spanGk1" + tempStr;
            $(idStr).style.zIndex = 10000;
            $(idStr).style.visibility = "hidden";
        }
    }
}

function hideWord()
{
    if (m_ovalList.length != 0)
    {
        for (var i = 0; i < m_ovalList.length; i ++)
        {
            var tempStr = m_ovalList[i].id;
            var idStr = "spanGk1" + tempStr;
            $(idStr).style.zIndex = 10000;
            $(idStr).style.visibility = "hidden";
        }
    }
}

var m_PntNo = 0;
var m_Scale;
function initpntdisp(entxml)
{
    var lstPipIndex = new Array();
    var xmlDoc = CtnXML.getXmlDoc();
    var vAGrid = 200;
    var vHalfGrid = vAGrid / 2;

    var vOffset = 5; //细微的偏移参数    
    
    var objDivPntMap = $("divPntmap");
    
    m_PntNo = 0;
    //绘制外框
    objDivPntMap.appendChild(MakeADiv("Frame", 0, makeLinStr(0, "black", vOffset, vOffset, 0, 0,          vAGrid * 3 , 0,          1, "")));
    objDivPntMap.appendChild(MakeADiv("Frame", 1, makeLinStr(1, "black", vOffset, vOffset, 0, vAGrid,     vAGrid * 3 , vAGrid,     1, "")));
    objDivPntMap.appendChild(MakeADiv("Frame", 2, makeLinStr(2, "black", vOffset, vOffset, 0, vAGrid * 2, vAGrid * 3 , vAGrid * 2, 1, "")));
    objDivPntMap.appendChild(MakeADiv("Frame", 3, makeLinStr(3, "black", vOffset, vOffset, 0, vAGrid * 3, vAGrid * 3 , vAGrid * 3, 1, "")));
	
    objDivPntMap.appendChild(MakeADiv("Frame", 4, makeLinStr(4, "black", vOffset, vOffset, 0,          0, 0,          vAGrid * 3 ,  1, "")));
    objDivPntMap.appendChild(MakeADiv("Frame", 5, makeLinStr(5, "black", vOffset, vOffset, vAGrid,     0, vAGrid,     vAGrid * 3 ,  1, "")));
    objDivPntMap.appendChild(MakeADiv("Frame", 6, makeLinStr(6, "black", vOffset, vOffset, vAGrid * 2, 0, vAGrid * 2, vAGrid * 3 ,  1, "")));
    objDivPntMap.appendChild(MakeADiv("Frame", 7, makeLinStr(7, "black", vOffset, vOffset, vAGrid * 3, 0, vAGrid * 3, vAGrid * 3 ,  1, "")));
	
	//设置框位置
    var temp1 = parseInt($("group1").style.width);
    var temp2 = parseInt($("group1").style.height);


    $("group1").style.width  = parseInt($("group1").style.width)  - 300 + "px";
    $("group1").style.height = parseInt($("group1").style.height) - 300 + "px";

    $("group1").style.left = parseInt($("group1").style.left) + 156 + "px";
    $("group1").style.top =  parseInt($("group1").style.top) + 64 + "px";

    //绘制管孔
    if (xmlDoc != null)
    {
        xmlDoc.loadXML(entxml);
        var nodes = xmlDoc.selectNodes('NewDataSet');
	    if(nodes.length == 0){return;}
        else
        {
            for (var i = 0; i < nodes.length; ++i)
            {
                 //取得管道编码
                var vPntNode = nodes[i].selectNodes("PNTBM");
                var vPntBm = null;
                var vPntRad = null;
                for (var j = 0; j < vPntNode.length; ++j)
                {
                   vPntBm = vPntNode[j].selectNodes("RSJBM");
                   vPntRad = vPntNode[j].selectNodes("RSJRAD");
                }
                m_Scale = 300/parseFloat(vPntRad[0].text);
                var vPnt = nodes[i].selectNodes("Table1");  
                m_PntNo = m_PntNo + vPnt.length;       
                for (var l = 0; l < vPnt.length; ++l)
                {
                    var bflag = false;
                    var vZtid = vPnt[l].selectNodes("ZTID")
                    var vId   = vPnt[l].selectNodes("ID0");
                    var vX0   = vPnt[l].selectNodes("X0");
                    var vY0   = vPnt[l].selectNodes("Y0");
                    var vX1   = vPnt[l].selectNodes("X1");
                    var vY1   = vPnt[l].selectNodes("Y1");
                    var vRad0 = vPnt[l].selectNodes("RAD0");
                    var vUsed = vPnt[l].selectNodes("USED");
                    var vQsBm = vPnt[l].selectNodes("QsBm");
                    var vZzBm = vPnt[l].selectNodes("ZzBm");
                    var item = new ovalItem(vId[0].text,vUsed[0].text);
                    m_ovalList.push(item);
                    var vInPipNo = vPnt[l].selectNodes("INPIPNO");
                    
                    if ((parseInt(vInPipNo[0].text)) == 0)
                    {
                        var vGddNodes = nodes[i].selectNodes("TeGdd");
                        for (var ll = 0; ll < vGddNodes.length; ++ll)
                        {
                            var vGddid = vGddNodes[ll].selectNodes("GDDNO")
                            if (vZtid[0].text == vGddid[0].text)
                            {
                                var vGddBm = vGddNodes[ll].selectNodes("GDDBM")
                                var vSplitGddBm = vGddBm[0].text;
                                var vArray = vSplitGddBm.split('-');
                                if (vArray[0] == vPntBm[0].text)
                                {
                                    bflag = true;
                                }
                            }
                        }                   
                        if (bflag == true)
                        {               
                            DrawGkong($("divPntmap"), vId, vX0, vY0, vRad0, vUsed, vQsBm);
                        }
                        else
                        {
                            DrawGkong($("divPntmap"), vId, vX1, vY1, vRad0, vUsed, vZzBm);
                        }
                    }
                    else
                    {
                        lstPipIndex.push(l);
                    }
                }//for 大管孔
                for (var k = 0; k < lstPipIndex.length; ++k)
                {
                    var Index = lstPipIndex[k];
                    var bflag = false;
                    var vZtid = vPnt[Index].selectNodes("ZTID")
                    var vId   = vPnt[Index].selectNodes("ID0");
                    var vX0   = vPnt[Index].selectNodes("X0");
                    var vY0   = vPnt[Index].selectNodes("Y0");
                    var vX1   = vPnt[Index].selectNodes("X1");
                    var vY1   = vPnt[Index].selectNodes("Y1");
                    var vRad0 = vPnt[Index].selectNodes("RAD0");
                    var vUsed = vPnt[Index].selectNodes("USED");
                    var vQsBm = vPnt[Index].selectNodes("QsBm");
                    var vZzBm = vPnt[Index].selectNodes("ZzBm");

                    var vGddNodes = nodes[i].selectNodes("TeGdd");
                    for (var ll = 0; ll < vGddNodes.length; ++ll)
                    {
                        var vGddid = vGddNodes[ll].selectNodes("GDDNO")
                        if (vZtid[0].text == vGddid[0].text)
                        {
                            var vGddBm = vGddNodes[ll].selectNodes("GDDBM")
                            var vSplitGddBm = vGddBm[0].text;
                            var vArray = vSplitGddBm.split('-');
                            if (vArray[0] == vPntBm[0].text)
                            {
                                bflag = true;
                            }
                        }
                    }                   
                    if (bflag == true)
                    {               
                        DrawGkong($("divPntmap"), vId, vX0, vY0, vRad0, vUsed, vQsBm);
                    }
                    else
                    {
                        DrawGkong($("divPntmap"), vId, vX1, vY1, vRad0, vUsed, vZzBm);
                    }
                }//for　小管孔
                SetTitle(vPntBm);
            }
        }
    }
//    if (pntNo != 0)
//    {
//        ToolBar();     //绘制工具条
//        //绘制外框
//	    objDivPntMap.appendChild(MakeADiv("Frame", 0, makeLinStr(0, "black", vOffset, vOffset, 0, 0,          vAGrid * 3 , 0,          1, "")));
//	    objDivPntMap.appendChild(MakeADiv("Frame", 1, makeLinStr(1, "black", vOffset, vOffset, 0, vAGrid,     vAGrid * 3 , vAGrid,     1, "")));
//	    objDivPntMap.appendChild(MakeADiv("Frame", 2, makeLinStr(2, "black", vOffset, vOffset, 0, vAGrid * 2, vAGrid * 3 , vAGrid * 2, 1, "")));
//	    objDivPntMap.appendChild(MakeADiv("Frame", 3, makeLinStr(3, "black", vOffset, vOffset, 0, vAGrid * 3, vAGrid * 3 , vAGrid * 3, 1, "")));
//    	
//	    objDivPntMap.appendChild(MakeADiv("Frame", 4, makeLinStr(4, "black", vOffset, vOffset, 0,          0, 0,          vAGrid * 3 ,  1, "")));
//	    objDivPntMap.appendChild(MakeADiv("Frame", 5, makeLinStr(5, "black", vOffset, vOffset, vAGrid,     0, vAGrid,     vAGrid * 3 ,  1, "")));
//	    objDivPntMap.appendChild(MakeADiv("Frame", 6, makeLinStr(6, "black", vOffset, vOffset, vAGrid * 2, 0, vAGrid * 2, vAGrid * 3 ,  1, "")));
//	    objDivPntMap.appendChild(MakeADiv("Frame", 7, makeLinStr(7, "black", vOffset, vOffset, vAGrid * 3, 0, vAGrid * 3, vAGrid * 3 ,  1, "")));
//    	
//    	//设置框位置
//	    var temp1 = parseInt($("group1").style.width);
//        var temp2 = parseInt($("group1").style.height);


//        $("group1").style.width  = parseInt($("group1").style.width)  - 300 + "px";
//        $("group1").style.height = parseInt($("group1").style.height) - 300 + "px";

//        $("group1").style.left = parseInt($("group1").style.left) + 156 + "px";
//        $("group1").style.top =  parseInt($("group1").style.top) + 64 + "px";
//    }
//    else
//    {
//        top.CtnDlg.warning("相关管道段中尚未录入任何管孔信息！");
//        return;
//    }
    
}

function DrawGkong(vDivGroup, vId, vX0, vY0, vRad0, vUsed, vstr)
{
      if (m_IsJwd == false)
      {
          var vAGrid = 200;
          var vOffset = 5; //细微的偏移参数
          var vtmpX0   = parseFloat(vX0[0].text);
          var vtmpY0   = parseFloat(vY0[0].text);
          var vtmpRAD0 = parseFloat(vRad0[0].text);
          var strtitle = vstr[0].text;
        
          var dot0 = new Array();

          dot0[0] = vtmpX0;
          dot0[1] = vtmpY0;
          
          vtmpX0 = dot0[0] * vAGrid + vAGrid / 2 + vAGrid + vOffset;     
          vtmpY0 = (dot0[1] * vAGrid - vAGrid * 1.5) * (-1) + vOffset;   
          vtmpRAD0 = vtmpRAD0 * vAGrid;
      }	
      else
      {
          var vOffset = 5; //细微的偏移参数
          var vtmpX0   = parseFloat(vX0[0].text);
          var vtmpY0   = parseFloat(vY0[0].text);
          var vtmpRAD0 = parseFloat(vRad0[0].text);
          var strtitle = vstr[0].text;
        
          var dot0 = new Array();

          dot0[0] = vtmpX0;
          dot0[1] = vtmpY0;
          
//          vtmpX0 = dot0[0] * vAGrid + vAGrid / 2 + vAGrid + vOffset;     
//          vtmpY0 = (dot0[1] * vAGrid - vAGrid * 1.5) * (-1) + vOffset;   
//          vtmpRAD0 = vtmpRAD0 * vAGrid;
          vtmpX0 = dot0[0]*m_Scale + 300 + vOffset;     
          vtmpY0 = (-1)*dot0[1] * m_Scale + 300 + vOffset;   
          vtmpRAD0 = vtmpRAD0 * m_Scale;
      }			  

      //绘制管孔;
      switch (vUsed[0].text)
      {
          case "0":  //空闲 
             vDivGroup.appendChild(MakeADiv("Cir", "Pnt"+vId[0].text, makeCirStr("Gk1"+vId[0].text , 0, 'blue', vtmpX0, vtmpY0, vtmpRAD0, strtitle)));
          break;
          case "1":  //占用（蓝色）
             vDivGroup.appendChild(MakeADiv("Cir", "Pnt"+vId[0].text,  makeCirStr("Gk1"+vId[0].text , 0, 'blue', vtmpX0, vtmpY0, vtmpRAD0, strtitle)));
             vDivGroup.appendChild(MakeADiv("Cir", "PntUse"+vId[0].text,  makePntCirStr("Gk1Use"+vId[0].text , 'blue', 'blue', vtmpX0, vtmpY0, vtmpRAD0/2, strtitle)));
             break;
          case "2":  //预占(绿色)
             vDivGroup.appendChild(MakeADiv("Cir", "Pnt"+vId[0].text,  makeCirStr("Gk1"+vId[0].text , 0, 'blue', vtmpX0, vtmpY0, vtmpRAD0, strtitle)));
             vDivGroup.appendChild(MakeADiv("Cir", "PntPreU"+vId[0].text,  makePntCirStr("Gk1PreU"+vId[0].text , 'green', 'green', vtmpX0, vtmpY0, vtmpRAD0/2, strtitle)));
             break;
          case "3":   //坏(蓝色，画叉)
              vDivGroup.appendChild(MakeADiv("Cir", "Pnt"+vId[0].text, makeCirStr("Gk1"+vId[0].text , 0, 'blue', vtmpX0, vtmpY0, vtmpRAD0, strtitle)));
              vDivGroup.appendChild(MakeADiv("Frame", 0,  makeLinStr(0, "red", 0, 0, vtmpX0 - vtmpRAD0, vtmpY0 - vtmpRAD0, vtmpX0 + vtmpRAD0, vtmpY0 + vtmpRAD0, 1, "")));
              vDivGroup.appendChild(MakeADiv("Frame", 0,  makeLinStr(0, "red", 0, 0, vtmpX0 - vtmpRAD0, vtmpY0 + vtmpRAD0, vtmpX0 + vtmpRAD0, vtmpY0 - vtmpRAD0, 1, "")));
              break;
          default:
            break;
      }
}

//获取缆线信息和附属设施信息
function getpntlxfs(response)
{
    if (!CtnError.validate(response.responseText))
    {
        CtnError.show();
        return;
    } 
    if (response.responseText == "|[]||[]||[]||[]||[]||[]||[]||[]||[]||[]||[]||[]||[]||[]||[]|") 
    {
        top.CtnDlg.warning("该设备没有缆线信息！");
        return;
    }
    var strxml = response.responseText;
    m_ActieTool = 1005;
    //解析xml 放到数组  存入div
    if (strxml != null)
    {
        var ArrStrXml = new Array();
        ArrStrXml = strxml.split("|[]|");
        var num = ArrStrXml.length;
    
        //打包成xml(顺序：树上的电缆、树上的光缆、
        //                气门气塞、传感器、电缆盘留、光缆盘留、电缆预留、光缆预留、电缆接头、光缆接头、
        //                in电缆节、in光缆节、in电缆节连接点、in光缆节连接点
        //                out电缆节、out光缆节)
        if (num == 16)
        {
            var index = 0;
            var strTreeXml = ArrStrXml[index] + "|[]|" + ArrStrXml[++index];
            vstrTreeXml = strTreeXml;
            $("divqmqs").innerHTML = ArrStrXml[++index];
            $("divcgq").innerHTML = ArrStrXml[++index];
            $("divdlpl").innerHTML = ArrStrXml[++index];
            $("divglpl").innerHTML = ArrStrXml[++index];
            $("divdlyl").innerHTML = ArrStrXml[++index];
            $("divglyl").innerHTML = ArrStrXml[++index];
            $("divdljt").innerHTML = ArrStrXml[++index];
            $("divgljt").innerHTML = ArrStrXml[++index];
            $("divindlj").innerHTML = ArrStrXml[++index];
            $("divinglj").innerHTML = ArrStrXml[++index];
            $("divindljljd").innerHTML = ArrStrXml[++index];
            $("divingljljd").innerHTML = ArrStrXml[++index];
            $("divoutdlj").innerHTML = ArrStrXml[++index];
            $("divoutglj").innerHTML = ArrStrXml[++index];
        
            if (strTreeXml != null)
            {
                top.CtnDlg.open("PntExpand/PntExpandTree.aspx", {title:"节点穿缆信息", width:400,height:500, srcwin:window,strtreexml:strTreeXml});
            }
        }
    }
}
    
function constructtredata()
{
    strxml = m_dlg.strtreexml;
    lxtree = new CtnTreeCtrl("lxtree",false);
    lxtree.create("funPagedivlxTree");
    var item = new cableItem(0,0,"",0,0);
    var nd     = lxtree.insertItem("节点穿缆信息", item);
    lxtree.show();
    nd.icon = 0;
    item = new cableItem(0,0,"电缆",0,0);
    var rtdlnd = nd.insertItem("电缆", item);
    rtdlnd.icon = 0;
    item = new cableItem(0,0,"光缆",0,0);
    var rtglnd = nd.insertItem("光缆", item);
    rtglnd.icon = 0;
    
    nd.show();
    
    lxtree.onSelectItem = m_dlg.srcwin.pntlxtreeonselectitem;
    lxtree.onRightMenu  = pntlxtreeonRightMenu;

    if (strxml != null)
    {
        //传过来的是电缆和光缆，需要拆分
        var ArrStrLxXml = new Array();
        ArrStrLxXml = strxml.split("|[]|");
        var num = ArrStrLxXml.length;

        //解析电缆
        if (ArrStrLxXml[0] != "")
        {
            constructtree(rtdlnd, rtdlnd, ArrStrLxXml[0],0);
        }
    
        //解析光缆
        if (ArrStrLxXml[1] != "")
        {
            constructtree(rtglnd, rtglnd, ArrStrLxXml[1],1);
        }
    }
}

function constructtree(tree, rootnode, strxml,type)
{
    var xmlDoc = CtnXML.getXmlDoc();
    if (xmlDoc != null)
    {
        xmlDoc.loadXML(strxml);
        var head = xmlDoc.selectNodes('PntLxLst');
        if(head.length == 0)
        {
            return;
        }
        else
        {            
            for (var i = 0; i < head.length; ++i)
            {
                var lxnd = head[i].selectNodes("Item");
                for (var l = 0; l < lxnd.length; ++l)
                {
                    var vLxType = lxnd[l].selectNodes("LxType");
                    var vLxNo   = lxnd[l].selectNodes("LxNo");
                    var vLxBm   = lxnd[l].selectNodes("LxBm");
                    var vLxMc   = lxnd[l].selectNodes("LxMc");

                    var lxtype = parseInt(vLxType[0].text);
                    var lxno   = parseInt(vLxNo[0].text);
                    var lxbm   = vLxBm[0].text;
                    var lxmc   = vLxMc[0].text;
                    
                    var item;
                    if (type == 0)  //电缆
                    {
                        item = new cableItem(vLxType[0].text,vLxNo[0].text,"","95","20");
                    }
                    else    //光缆
                    {
                        item = new cableItem(vLxType[0].text,vLxNo[0].text,"","95","30");
                    }
                    
                    var trlxnd = tree.insertItem(lxbm + "(" + lxmc + ")", item);
                    

                    var ldnd = lxnd[l].selectNodes("LdItem");
                    for (var j = 0; j < ldnd.length; ++j)
                    {
                        var vLdType = ldnd[j].selectNodes("LdType");
                        var vLdNo   = ldnd[j].selectNodes("LdNo");
                        var vLdBm   = ldnd[j].selectNodes("LdBm");
                        
                        var ldtype = parseInt(vLdType[0].text);
                        var ldno   = parseInt(vLdNo[0].text);
                        var ldbm   = vLdBm[0].text;
                        
                        var item;
                        if (type == 0)  //电缆
                        {
                            item = new cableItem(vLdType[0].text,vLdNo[0].text,"","95","21");
                        }
                        else    //光缆
                        {
                            item = new cableItem(vLdType[0].text,vLdNo[0].text,"","95","31");
                        }
                        var trldnd = trlxnd.insertItem(ldbm, item);
                        trldnd.bend = 1;
                    }
                    
                }
            }
        }
    }
}

//赵坤
function FindLdByLxType(LxType, LxID0, ArrayLxdNo)
{
    var LxTree = vstrTreeXml;
    var ArrLxTree = LxTree.split("|[]|");
    var TempLxDl    =  ArrLxTree[0];
    var TempLxGl    =  ArrLxTree[1];
    TempLxDl = TempLxDl.toUpperCase();
    TempLxGl = TempLxGl.toUpperCase();
    var xmlDoc = CtnXML.getXmlDoc();
    if (LxType == 20)
    {
        if (xmlDoc != null)
        {
            xmlDoc.loadXML(TempLxDl);
            var head = xmlDoc.selectNodes('PNTLXLST');
            if(head.length == 0)
            {
                return;
            }
            else
            {            
                for (var i = 0; i < head.length; ++i)
                {
                    var lxnd = head[i].selectNodes("ITEM");
                    for (var l = 0; l < lxnd.length; ++l)
                    {
                        var vLxNo   = lxnd[l].selectNodes("LXNO");
                        if (LxID0 == parseInt(vLxNo[0].text))
                        {
                            var ldnd = lxnd[l].selectNodes("LDITEM");
                            for (var j = 0; j < ldnd.length; ++j)
                            {
                               var vLdNo   = ldnd[j].selectNodes("LDNO");
                               ArrayLxdNo.push(parseInt(vLdNo[0].text));
                            }
                        }
        
                    }
                }
            }
        }
    }
    else if (LxType == 30)
    {
        if (xmlDoc != null)
        {
            xmlDoc.loadXML(TempLxGl);
            var head = xmlDoc.selectNodes('PNTLXLST');
            if(head.length == 0)
            {
                return;
            }
            else
            {            
                for (var i = 0; i < head.length; ++i)
                {
                    var lxnd = head[i].selectNodes("ITEM");
                    for (var l = 0; l < lxnd.length; ++l)
                    {
                        var vLxNo   = lxnd[l].selectNodes("LXNO");
                        if (LxID0 == parseInt(vLxNo[0].text))
                        {
                            var ldnd = lxnd[l].selectNodes("LDITEM");
                            for (var j = 0; j < ldnd.length; ++j)
                            {
                               var vLdNo   = ldnd[j].selectNodes("LDNO");
                               ArrayLxdNo.push(parseInt(vLdNo[0].text));
                            }
                        }
        
                    }
                }
            }
        }
    }
}

var _time = 0;
var _glbLxnd;
var _glbI = 0;
var _glbNum = 10;
var _operFlag;    //0表示显示电缆，1表示显示光缆
//赵坤
function pntlxtreeonselectitem(Choose)//自定义方法的实现
{
    //删除ArrayRemoveByID数组里的id
    if (ArrayRemoveByID.length != 0)
    {
        for (var iMove = ArrayRemoveByID.length-1; iMove >= 0 ; iMove--)
        {
            var MoveID = ArrayRemoveByID[iMove];
            var objMove = document.getElementById(MoveID);
            objMove.innerHTML = "";
            $("divPntmap").removeChild(objMove);
            ArrayRemoveByID.pop(iMove);
        }      
    }
    
    var currentnode = Choose;//得到当前选中的节点    //var TypeId = currentnode.getItemData();
    var info = currentnode.getItemData();
    var LxName = info.type;
    var xmlDoc = CtnXML.getXmlDoc();
    if (LxName == "电缆")
    {
        var LxTree = vstrTreeXml;
        var ArrLxTree = LxTree.split("|[]|");
        var TempLxDl    =  ArrLxTree[0];
        TempLxDl = TempLxDl.toUpperCase();

        if (xmlDoc != null)
        {
            xmlDoc.loadXML(TempLxDl);
            var head = xmlDoc.selectNodes('PNTLXLST');
            if(head.length == 0)
            {
                return;
            }
            else
            {           
                top.CtnDlg.loading("系统忙，请稍候...");
                _operFlag = 0;
                for (var i = 0; i < head.length; ++i)
                {
                    _glbI = 0;
                    _glbNum = 10;
                    _glbLxnd = head[i].selectNodes("ITEM");
                    setTimeout("DoTimerDisp()",100);
                 }
             }
         }
         
         return;      
    }
    else if (LxName == "光缆")
    {   
        var LxTree = vstrTreeXml;
        var ArrLxTree = LxTree.split("|[]|");
        var TempLxGl    =  ArrLxTree[1];
        TempLxGl = TempLxGl.toUpperCase();
        if (xmlDoc != null)
        {
            xmlDoc.loadXML(TempLxGl);
            var head = xmlDoc.selectNodes('PNTLXLST');
            if(head.length == 0)
            {
                return;
            }
            else
            {    
                top.CtnDlg.loading("系统忙，请稍候..."); 
                _operFlag = 1;
                for (var i = 0; i < head.length; ++i)
                {
                    _glbI = 0;
                    _glbNum = 10;
                    _glbLxnd = head[i].selectNodes("ITEM");
                    setTimeout("DoTimerDisp()",100);
                 }
                 
             }
         }
         
         return;
    }

    if (info.typeID1 != 0 && info.typeID2 != 0)
    {  
        DrawLx(info.typeID1, info.typeID2);
    }
}

function pntlxtreeonRightMenu(item, evt)
{
    var entid = item.data.typeID2;
    var major = item.data.major;
    var minor = item.data.minor;
    mc = new CtnMenuCtrl("mc");
    with(mc)
    {
        addEvent("查看属性" ,"top.ExecuteATool(top.m_vt.FUN_ATT,["+major+", "+minor+", "+entid+", 'view', null])");
        addEvent("设施定位", "top.ExecuteATool(top.m_vt.FUN_LOC,["+major+", "+minor+", "+entid+"])");
    }
    mc.show(evt);
}

function DoTimerDisp()
{
    for (var l = _glbI; l < _glbNum; ++l)
    {
        if (l >= _glbLxnd.length)
        {
            top.CtnDlg.unloading();
            clearTimeout(_time);
            return;
        }
        var vLxNo   = _glbLxnd[l].selectNodes("LXNO");
        if (_operFlag == 0)
        {
            DrawLx('20', vLxNo[0].text);        //绘制电缆线
        }
        else
        {
            DrawLx('30', vLxNo[0].text);        //绘制光缆线
        }
    }
     _glbI = _glbI + 10;
     _glbNum = _glbNum + 10;
    _time = setTimeout("DoTimerDisp()",100);
}

function DrawLx(LxLx, inLxID)
{
        var xmlDoc  = CtnXML.getXmlDoc();
        if (LxLx == '21')
        {   
            var LxID = parseInt(inLxID);
            //节点内电缆节XML
            var strInDlj = $("divindlj").innerHTML;
            strInDlj = "<NEWDATASET><TABLE1><ID0>" + strInDlj;
            //节点外电缆节XML
            var strOutDlj = $("divoutdlj").innerHTML;
            strOutDlj = "<NEWDATASET><TABLE1><ID0>" + strOutDlj;
            //电缆节连接点
            var strDljLjd = $("divindljljd").innerHTML;
            strDljLjd = "<NEWDATASET><TABLE1><ID0>" + strDljLjd;
            //气门气筛
            var strQmqs = $("divqmqs").innerHTML;
            if (strQmqs != "")
            {
                strQmqs = "<NEWDATASET><TABLE1><ID0>" + strQmqs;
            }
            //电缆盘留    
            var strDlPL = $("divdlpl").innerHTML;
            if (strDlPL != "")
            {
                strDlPL = "<NEWDATASET><TABLE1><ID0>" + strDlPL;
            }
            //电缆预留
            var strDlYl = $("divdlyl").innerHTML;
            if (strDlYl != "")
            {
                strDlYl = "<NEWDATASET><TABLE1><ID0>" + strDlYl;
            }
            //画缆线段
            Drawld(LxID, 21, strInDlj, strOutDlj, strDljLjd, strQmqs, strDlPL, strDlYl);
        }
        else if(LxLx == '31')
        {
            var LxID = parseInt(inLxID);
            var strInGlj = $("divinglj").innerHTML;
            strInGlj = "<NEWDATASET><TABLE1><ID0>" + strInGlj;
            var strOutGlj = $("divoutglj").innerHTML;
            strOutGlj = "<NEWDATASET><TABLE1><ID0>" + strOutGlj;
            var strGljLjd = $("divingljljd").innerHTML;
            strGljLjd = "<NEWDATASET><TABLE1><ID0>" + strGljLjd;
            //气门气塞
            var strQmqs = $("divqmqs").innerHTML;
            if (strQmqs != "")
            {
                strQmqs = "<NEWDATASET><TABLE1><ID0>" + strQmqs;
            }
            //光缆盘留    
            var strGlPL = $("divglpl").innerHTML;
            if (strGlPL != "")
            {
                strGlPL = "<NEWDATASET><TABLE1><ID0>" + strGlPL;
            }
            //光缆预留
            var strGlYl = $("divglyl").innerHTML;
            if (strGlYl != "")
            {
                strGlYl = "<NEWDATASET><TABLE1><ID0>" + strGlYl;
            }
            //画光缆段      
            Drawld(LxID, 31, strInGlj, strOutGlj, strGljLjd, strQmqs, strGlPL, strGlYl);
        }
        else if (LxLx == '20')
        {
            var strInDlj = $("divindlj").innerHTML;
            strInDlj = "<NEWDATASET><TABLE1><ID0>" + strInDlj;
            var strOutDlj = $("divoutdlj").innerHTML;
            strOutDlj = "<NEWDATASET><TABLE1><ID0>" + strOutDlj;
            var strDljLjd = $("divindljljd").innerHTML;
            strDljLjd = "<NEWDATASET><TABLE1><ID0>" + strDljLjd;
            //气门气筛
            var strQmqs = $("divqmqs").innerHTML;
            if (strQmqs != "")
            {
                strQmqs = "<NEWDATASET><TABLE1><ID0>" + strQmqs;
            }
            //电缆盘留    
            var strDlPL = $("divdlpl").innerHTML;
            if (strDlPL != "")
            {
                strDlPL = "<NEWDATASET><TABLE1><ID0>" + strDlPL;
            }
            //电缆预留
            var strDlYl = $("divdlyl").innerHTML;
            if (strDlYl != "")
            {
                strDlYl = "<NEWDATASET><TABLE1><ID0>" + strDlYl;
            }
            //传感器            
            var strCgq = $("divcgq").innerHTML;
            if (strCgq != "")
            {
                strCgq = "<NEWDATASET><TABLE1><ID0>" + strCgq;

                xmlDoc.loadXML(strCgq);
                var nodes = xmlDoc.selectNodes('NEWDATASET');
                if(nodes.length != 0)
                {       
                    for (var iCgq = 0; iCgq < nodes.length; iCgq++)
                    {
                        var vTable1 = nodes[iCgq].selectNodes("TABLE1"); //           
                        for (var jCgq = 0; jCgq < vTable1.length; jCgq++)
                        {
                            var vGlid = vTable1[jCgq].selectNodes("GLID");
                            if (inLxID ==  parseInt(vGlid[0].text))
                            {
                                var Id0 = vTable1[jCgq].selectNodes("ID0");
                                var x0 = vTable1[jCgq].selectNodes("X0");
                                var y0 = vTable1[jCgq].selectNodes("Y0");
                                var rad = vTable1[jCgq].selectNodes("RAD");
                                var bm  = vTable1[jCgq].selectNodes("BM");
                                
                                Id0 = parseInt(Id0[0].text);
                                x0 = parseFloat(x0[0].text);
                                y0 = parseFloat(y0[0].text);
                                rad = parseFloat(rad[0].text);
                                bm = bm[0].text;
                                //支持电杆图
                                if (m_pntMajor == 1 && m_pntMinor == 16)
                                {
                                    x0 = x0 * 300 + 5;
                                    y0 = y0 * 300 * (-1) + 5;
                                    rad = rad * 300;
                                }
                                else if(m_pntMajor == 1 && m_pntMinor == 17)//支持承佃
                                {
                                    x0 = x0 * 600 + 5;
                                    y0 = y0 * 600 * (-1) + 5;
                                    rad = rad * 600;
                                }
                                else//支持井图
                                {
                                    x0 = x0 * 200 + 200 / 2 + 200 + 5;
                                    y0 = (y0 * 200 - 200 * 1.5) * (-1) + 5;
                                    rad = rad * 200;
                                }
 
                                //调画qmqs函数
                                var strVal = dispcgq(x0, y0, rad, bm);
                                //往ArrayRemoveByID数组里添加个ID纪录，好让下次擦除
                                var RemoveID = "Pnt" + Id0;
                                ArrayRemoveByID.push(RemoveID);
                                //画
                                $("divPntmap").appendChild(MakeADiv("Cir", "Pnt" + Id0, strVal));
                            }
                        }
                    }
                }
                
            }
            //end传感器
            
            //电缆接头
            var  strDljt = $("divdljt").innerHTML;
            if (strDljt != "")
            {
                strDljt = "<NEWDATASET><TABLE1><ID0>" + strDljt;
                xmlDoc.loadXML(strDljt);
                var nodes = xmlDoc.selectNodes('NEWDATASET');
                if(nodes.length != 0)
                {       
                    for (var iDljt = 0; iDljt < nodes.length; iDljt++)
                    {
                        var vTable1 = nodes[iDljt].selectNodes("TABLE1"); //           
                        for (var jDljt = 0; jDljt < vTable1.length; jDljt++)
                        {
                            var vGlid = vTable1[jDljt].selectNodes("GLID");
                            if (inLxID ==  parseInt(vGlid[0].text))
                            {
                                var Id0 = vTable1[jDljt].selectNodes("ID0");
                                var x0 = vTable1[jDljt].selectNodes("X0");
                                var y0 = vTable1[jDljt].selectNodes("Y0");
                                var rad = vTable1[jDljt].selectNodes("RAD");
                                var bm  = vTable1[jDljt].selectNodes("BM");
                                
                                Id0 = parseInt(Id0[0].text);
                                x0 = parseFloat(x0[0].text);
                                y0 = parseFloat(y0[0].text);
                                rad = parseFloat(rad[0].text);
                                bm = bm[0].text;
                                                               //支持电杆图
                                if (m_pntMajor == 1 && m_pntMinor == 16)
                                {
                                    x0 = x0 * 300 + 5;
                                    y0 = y0 * 300 * (-1) + 5;
                                    rad = rad * 300;
                                }
                                else if (m_pntMajor == 1 && m_pntMinor == 17)//支持承佃
                                {
                                    x0 = x0 * 600 + 5;
                                    y0 = y0 * 600 * (-1) + 5;
                                    rad = rad * 600;
                                }
                                else                            //支持井图
                                {
                                    x0 = x0 * 200 + 200 / 2 + 200 + 5;
                                    y0 = (y0 * 200 - 200 * 1.5) * (-1) + 5;
                                    rad = rad * 200;
                                }    
                                //调画Dljt函数
                                var strVal = dispjt(20, x0, y0, rad, bm);
                                //往ArrayRemoveByID数组里添加个ID纪录，好让下次擦除
                                var RemoveID = "Pnt" + Id0;
                                ArrayRemoveByID.push(RemoveID);
                                //画
                                $("divPntmap").appendChild(MakeADiv("Cir", "Pnt" + Id0, strVal));
                            }
                        }
                    }
                }
                
            }
            //end电缆接头               
            var ArrayLxdNo = new Array();
            
            FindLdByLxType(20, inLxID, ArrayLxdNo);
                 
            for (var m = 0; m < ArrayLxdNo.length; m++)
            {
                Drawld(ArrayLxdNo[m], 21, strInDlj, strOutDlj, strDljLjd, strQmqs, strDlPL, strDlYl);
            }
        }
        else if (LxLx == '30')
        {   
            var strInGlj = $("divinglj").innerHTML;
            strInGlj = "<NEWDATASET><TABLE1><ID0>" + strInGlj;
            var strOutGlj = $("divoutglj").innerHTML;
            strOutGlj = "<NEWDATASET><TABLE1><ID0>" + strOutGlj;
            var strGljLjd = $("divingljljd").innerHTML;
            strGljLjd = "<NEWDATASET><TABLE1><ID0>" + strGljLjd;
             //气门气塞
            var strQmqs = $("divqmqs").innerHTML;
            if (strQmqs != "")
            {
                strQmqs = "<NEWDATASET><TABLE1><ID0>" + strQmqs;
            }
            //光缆盘留    
            var strGlPL = $("divglpl").innerHTML;
            if (strGlPL != "")
            {
                strGlPL = "<NEWDATASET><TABLE1><ID0>" + strGlPL;
            }
            //光缆预留
            var strGlYl = $("divglyl").innerHTML;
            if (strGlYl != "")
            {
                strGlYl = "<NEWDATASET><TABLE1><ID0>" + strGlYl;
            }
            //光缆接头
            var  strGljt = $("divgljt").innerHTML;
            if (strGljt != "")
            {
                strGljt = "<NEWDATASET><TABLE1><ID0>" + strGljt;
                xmlDoc.loadXML(strGljt);
                var nodes = xmlDoc.selectNodes('NEWDATASET');
                if(nodes.length != 0)
                {       
                    for (var iGljt = 0; iGljt < nodes.length; iGljt++)
                    {
                        var vTable1 = nodes[iGljt].selectNodes("TABLE1"); //           
                        for (var jGljt = 0; jGljt < vTable1.length; jGljt++)
                        {
                            var vGlid = vTable1[jGljt].selectNodes("GLID");
                            if (inLxID ==  parseInt(vGlid[0].text))
                            {
                                var Id0 = vTable1[jGljt].selectNodes("ID0");
                                var x0 = vTable1[jGljt].selectNodes("X0");
                                var y0 = vTable1[jGljt].selectNodes("Y0");
                                var rad = vTable1[jGljt].selectNodes("RAD");
                                var bm = vTable1[jGljt].selectNodes("BM");
                                
                                Id0 = parseInt(Id0[0].text);
                                x0 = parseFloat(x0[0].text);
                                y0 = parseFloat(y0[0].text);
                                rad = parseFloat(rad[0].text);
                                bm  = bm[0].text;
                                                               //支持电杆图
                                if (m_pntMajor == 1 && m_pntMinor == 16)
                                {
                                    x0 = x0 * 300 + 5;
                                    y0 = y0 * 300 * (-1) + 5;
                                    rad = rad * 300;
                                }
                                else if (m_pntMajor == 1 && m_pntMinor == 17)//支持承佃
                                {
                                    x0 = x0 * 600 + 5;
                                    y0 = y0 * 600 * (-1) + 5;
                                    rad = rad * 600;
                                }
                                else                            //支持井图
                                {
                                    x0 = x0 * 200 + 200 / 2 + 200 + 5;
                                    y0 = (y0 * 200 - 200 * 1.5) * (-1) + 5;
                                    rad = rad * 200;
                                }
                                //调画Dljt函数
                                var strVal = dispjt(30, x0, y0, rad, bm);
                                //往ArrayRemoveByID数组里添加个ID纪录，好让下次擦除
                                var RemoveID = "Pnt" + Id0;
                                ArrayRemoveByID.push(RemoveID);
                                //画
                                $("divPntmap").appendChild(MakeADiv("Cir", "Pnt" + Id0, strVal));
                            }
                        }
                    }
                }
                
            }
            //end光缆接头            
             
            var ArrayLxdNo = new Array();
            FindLdByLxType(30, inLxID, ArrayLxdNo);
            
            for (var m = 0; m < ArrayLxdNo.length; m++)
            {
                Drawld(ArrayLxdNo[m], 31, strInGlj, strOutGlj, strGljLjd, strQmqs, strGlPL, strGlYl);
            }
        }

}

//绘制缆线段函数
function Drawld(LxID, LxType, strInDlj, strOutDlj, strDljLjd, strQmqs, strPL, strYl)
{
    var vAGrid = 200;//人手井放大倍数
    var vAGridDg = 300;//电杆放大倍数   
    var vAGridZCD = 600; 
    var vOffset = 5; //细微的偏移参数
     var DrawDljljd = new Array();
    var ArrayInDljFnt = new Array();
    var ArrayInDljTal = new Array();
    var ArrayOutDlj = new Array();
    var ArrayDljLjd = new Array();
    var xmlDoc      = CtnXML.getXmlDoc();
    //开始解析这些字符串
    //1、先解析DlJ的GLID是否与LxID相等，相等的就把DlJ存到数组中。
    //1.1、解析strOutDlj前节点和后节点，如果strOutDlj有前节点和后节点等同于strInDlj前节点和后节点，那么就认为它为穿出
    //2、得到电缆节的id0数组然后再逐一找到电缆节连接点，得到每一个电缆接连点的x0,y0把线画出来
    if (xmlDoc != null)
    {   //第1步        
        xmlDoc.loadXML(strInDlj);
        var nodes = xmlDoc.selectNodes('NEWDATASET');
        if(nodes.length == 0)
        {
            return;
        }
        else
        {
            for (var i = 0; i < nodes.length; i++)
            {
                var vTable1 = nodes[i].selectNodes("TABLE1"); //           
                for (var j = 0; j < vTable1.length; j++)
                {
                    var vGlid = vTable1[j].selectNodes("GLID");
                    if ( parseInt(vGlid[0].text) ==  LxID)
                    {
                        var vFntljd = vTable1[j].selectNodes("FNTLJD");
                        var vTalljd = vTable1[j].selectNodes("TALLJD");
                        ArrayInDljFnt.push(parseInt(vFntljd[0].text));
                        ArrayInDljTal.push(parseInt(vTalljd[0].text));
                    }
                }
            }
        }
        //气门气塞
        xmlDoc.loadXML(strQmqs);
        var nodes = xmlDoc.selectNodes('NEWDATASET');
        if(nodes.length != 0)
        {       
            for (var iQmqs = 0; iQmqs < nodes.length; iQmqs++)
            {
                var vTable1 = nodes[iQmqs].selectNodes("TABLE1"); //           
                for (var jQmqs = 0; jQmqs < vTable1.length; jQmqs++)
                {
                    var vGlid = vTable1[jQmqs].selectNodes("GLID");
                    if ( parseInt(vGlid[0].text) ==  LxID)
                    {
                        var Id0 = vTable1[jQmqs].selectNodes("ID0");
                        var x0 = vTable1[jQmqs].selectNodes("X0");
                        var y0 = vTable1[jQmqs].selectNodes("Y0");
                        var rad = vTable1[jQmqs].selectNodes("RAD");
                        var bm  = vTable1[jQmqs].selectNodes("BM");
                        Id0 = parseInt(Id0[0].text);
                        x0 = parseFloat(x0[0].text);
                        y0 = parseFloat(y0[0].text);
                        rad = parseFloat(rad[0].text);
                        bm  = bm[0].text;
                                                       //支持电杆图
                        if (m_pntMajor == 1 && m_pntMinor == 16)
                        {
                             x0 = x0 * vAGridDg + 5;
                             y0 = y0 * vAGridDg * (-1) + 5;
                             rad = rad * vAGridDg;
                        }
                        else if (m_pntMajor == 1 && m_pntMinor == 17)//支撑承佃
                        {
                              x0 = x0 * vAGridZCD + 5;
                             y0 = y0 * vAGridZCD * (-1) + 5;
                             rad = rad * vAGridZCD;                           
                        }
                        else                           //支持井图
                        {
                            x0 = x0 * vAGrid + vAGrid / 2 + vAGrid + vOffset;
                            y0 = (y0 * vAGrid - vAGrid * 1.5) * (-1) + vOffset;
                            rad = rad * vAGrid;
                        }
                        //调画qmqs函数
                        var strVal = dispqmqs(x0, y0, rad, bm);
                        //往ArrayRemoveByID数组里添加个ID纪录，好让下次擦除
                        var RemoveID = "Pnt" + Id0;
                        ArrayRemoveByID.push(RemoveID);
                        //画
                        $("divPntmap").appendChild(MakeADiv("Cir", "Pnt" + Id0, strVal));

                    }
                }
            }
        }
        //end 气门气塞
        
        //盘留
        xmlDoc.loadXML(strPL);
        var nodes = xmlDoc.selectNodes('NEWDATASET');
        if(nodes.length != 0)
        {       
            for (var iPl = 0; iPl < nodes.length; iPl++)
            {
                var vTable1 = nodes[iPl].selectNodes("TABLE1"); //           
                for (var jPl = 0; jPl < vTable1.length; jPl++)
                {
                    var vGlid = vTable1[jPl].selectNodes("GLID");
                    if ( parseInt(vGlid[0].text) ==  LxID)
                    {   
                        var Id0 = vTable1[jPl].selectNodes("ID0");
                        var x0 = vTable1[jPl].selectNodes("X0");
                        var y0 = vTable1[jPl].selectNodes("Y0");
                        var rad = vTable1[jPl].selectNodes("RAD");
                        var bm  = vTable1[jPl].selectNodes("BM");
                        
                        Id0 = parseInt(Id0[0].text);
                        x0 = parseFloat(x0[0].text);
                        y0 = parseFloat(y0[0].text);
                        rad = parseFloat(rad[0].text);
                        bm  = bm[0].text;
                                                                               //支持电杆图
                        if (m_pntMajor == 1 && m_pntMinor == 16)
                        {
                             x0 = x0 * vAGridDg + 5;
                             y0 = y0 * vAGridDg * (-1) + 5;
                             rad = rad * vAGridDg;
                        }
                        else if (m_pntMajor == 1 && m_pntMinor == 17)//支撑承佃
                        {
                             x0 = x0 * vAGridZCD + 5;
                             y0 = y0 * vAGridZCD * (-1) + 5;
                             rad = rad * vAGridZCD;
                        }
                        else                                                    //支持井图
                        {
                            x0 = x0 * vAGrid + vAGrid / 2 + vAGrid + vOffset;
                            y0 = (y0 * vAGrid - vAGrid * 1.5) * (-1) + vOffset;
                            rad = rad * vAGrid;
                        }
                        //调画盘留函数
                        var strVal = disppl(LxType, x0, y0, rad, bm);
                        //往ArrayRemoveByID数组里添加个ID纪录，好让下次擦除
                        var RemoveID = "Pnt" + Id0;
                        ArrayRemoveByID.push(RemoveID);
                        //画
                        $("divPntmap").appendChild(MakeADiv("Cir", "Pnt"+ Id0, strVal));
                    }
                }
            }
        }
        //end 盘留
        
        //预留
        xmlDoc.loadXML(strYl);
        //XmlDoc = strYl;
        var nodes = xmlDoc.selectNodes('NEWDATASET');
        if(nodes.length != 0)
        {       
            for (var iYl = 0; iYl < nodes.length; iYl++)
            {
                var vTable1 = nodes[iYl].selectNodes("TABLE1"); //           
                for (var jYl = 0; jYl < vTable1.length; jYl++)
                {
                    var vGlid = vTable1[jYl].selectNodes("GLID");
                    if ( parseInt(vGlid[0].text) ==  LxID)
                    {   
                        var Id0 = vTable1[jYl].selectNodes("ID0");
                        var x0 = vTable1[jYl].selectNodes("X0");
                        var y0 = vTable1[jYl].selectNodes("Y0");
                        var rad = vTable1[jYl].selectNodes("RAD");
                        var bm  = vTable1[jYl].selectNodes("BM");
                        
                        Id0 = parseInt(Id0[0].text);
                        x0 = parseFloat(x0[0].text);
                        y0 = parseFloat(y0[0].text);
                        rad = parseFloat(rad[0].text);
                        bm  = bm[0].text;
                                                                               //支持电杆图
                        if (m_pntMajor == 1 && m_pntMinor == 16)
                        {
                             x0 = x0 * vAGridDg + 5;
                             y0 = y0 * vAGridDg * (-1) + 5;
                             rad = rad * vAGridDg;
                        }
                        else if (m_pntMajor == 1 && m_pntMinor == 17)//支撑承佃
                        {
                              x0 = x0 * vAGridZCD + 5;
                             y0 = y0 * vAGridZCD * (-1) + 5;
                             rad = rad * vAGridZCD;                           
                        }
                        else                                                //支持井图
                        {
                            x0 = x0 * vAGrid + vAGrid / 2 + vAGrid + vOffset;
                            y0 = (y0 * vAGrid - vAGrid * 1.5) * (-1) + vOffset;
                            rad = rad * vAGrid;
                        }
                        //调画盘留函数
                        var strVal = dispyl(LxType, x0, y0, rad, bm);
                        //往ArrayRemoveByID数组里添加个ID纪录，好让下次擦除
                        var RemoveID = "Pnt" + Id0;
                        ArrayRemoveByID.push(RemoveID);
                        //画
                        $("divPntmap").appendChild(MakeADiv("Cir", "Pnt"+ Id0, strVal));
                    }
                }
            }
        }
        //end预留
        //第1步完成
        //第１．１步
        xmlDoc.loadXML(strOutDlj);
        //XmlDoc = strOutDlj;
        var nodes = xmlDoc.selectNodes('NEWDATASET');
        if(nodes.length == 0)
        {
            return;
        }
        else
        {
            for (var i = 0; i < nodes.length; i++)
            {
                var vTable1 = nodes[i].selectNodes("TABLE1"); //           
                for (var j = 0; j < vTable1.length; j++)
                {
                    var vGlid = vTable1[j].selectNodes("GLID");
                    if ( parseInt(vGlid[0].text) ==  LxID)
                    {
                        var vOutFntljd = vTable1[j].selectNodes("FNTLJD");
                        var vOutTalljd = vTable1[j].selectNodes("TALLJD");
                        
                        for (var ii = 0; ii < ArrayInDljFnt.length; ii++)
                        {
                            if (ArrayInDljFnt[ii] == parseInt(vOutFntljd[0].text) || ArrayInDljFnt[ii] == parseInt(vOutTalljd[0].text))
                            {
                                DrawDljljd.push(ArrayInDljFnt[ii]);
                            }
                        }
                        for (var jj = 0; jj < ArrayInDljTal.length; jj++)
                        {
                            if (ArrayInDljTal[jj] == parseInt(vOutFntljd[0].text) || ArrayInDljTal[jj] == parseInt(vOutTalljd[0].text))
                            {
                                DrawDljljd.push(ArrayInDljTal[jj]);
                            }
                        }
                    }
                }
            }
        }
              
        //第2步
        xmlDoc.loadXML(strDljLjd);
        //XmlDoc = strDljLjd;
        var nodes = xmlDoc.selectNodes('NEWDATASET');
        if(nodes.length == 0)
        {
            return;
        }
        else
        {
            for (var i = 0; i < ArrayInDljFnt.length; i++)
            {   
                var x0 = 0, y0 = 0, x1 = 0, y1 = 0, rad, ZkX0 = 0, ZkY0 = 0,ZkX1 = 0, ZkY1 = 0;//
                var TempX0 = 0, TempY0 = 0, TempX1 = 0, TempY1 = 0;
                var vID0 = 0;
                var vDljFnt = parseInt(ArrayInDljFnt[i]);
                var vDljTal = parseInt(ArrayInDljTal[i]);
                var vFlag  = 0;
                
                for (var j = 0; j < nodes.length; j++)
                {
                    var vTable1 = nodes[j].selectNodes("TABLE1");           
                    for (var k = 0; k < vTable1.length; k++)
                    {   
                        vID0 = vTable1[k].selectNodes("ID0");
                        if (vDljFnt == parseInt(vID0[0].text))
                        {
                            if (m_pntMajor == 1 && m_pntMinor == 16)//电杆型
                            {
                                rad = vTable1[k].selectNodes("RAD");
                                rad = parseInt(rad[0].text);
                                rad = 0.015 * vAGridDg/1.7;
                                
                                TempX0 = vTable1[k].selectNodes("X0");
                                x0 = parseFloat(TempX0[0].text);
                                x0 = x0 * vAGridDg +　vOffset;

                                TempY0 = vTable1[k].selectNodes("Y0");
                                y0 = parseFloat(TempY0[0].text);
                                y0 = y0 * vAGridDg * (-1) + vOffset;
                                vFlag = 1;
                            }
                            else if (m_pntMajor == 1 && m_pntMinor == 17) //支撑点行
                            {   
                                rad = vTable1[k].selectNodes("RAD");
                                rad = parseInt(rad[0].text);
                                rad = 0.006 * vAGridZCD/1.7;
                                
                                TempX0 = vTable1[k].selectNodes("X0");
                                x0 = parseFloat(TempX0[0].text);
                                x0 = x0 * vAGridZCD +　vOffset;

                                TempY0 = vTable1[k].selectNodes("Y0");
                                y0 = parseFloat(TempY0[0].text);
                                y0 = y0 * vAGridZCD * (-1) + vOffset;
                                vFlag = 1;
                            }
                            else                                //井型
                            {
                                rad = vTable1[k].selectNodes("RAD");
                                rad = parseInt(rad[0].text);
                                if (rad == 0)
                                {
                                    rad = 0.03 * vAGrid/1.7;
                                }
                                else
                                {
                                    rad = rad * vAGrid/1.7;
                                }
                                TempX0 = vTable1[k].selectNodes("X0");
                                x0 = parseFloat(TempX0[0].text);
                                x0 = x0 * vAGrid + vAGrid / 2 + vAGrid + vOffset;
                            
                                TempY0 = vTable1[k].selectNodes("Y0");
                                y0 = parseFloat(TempY0[0].text);
                                y0 = (y0 * vAGrid - vAGrid * 1.5) * (-1) + vOffset;
                                vFlag = 1;
                            }
                            //continue;
                        }
                        else if (vDljTal == parseInt(vID0[0].text))
                        {
                            if (m_pntMajor == 1 && m_pntMinor == 16)//电杆型
                            {
                                rad = vTable1[k].selectNodes("RAD");
                                rad = rad[0].text;
                                rad = 0.015 * vAGridDg/1.7;
        
                                TempX1 = vTable1[k].selectNodes("X0");
                                x1 = parseFloat(TempX1[0].text);
                                x1 = x1 * vAGridDg + vOffset;
                            
                                TempY1 = vTable1[k].selectNodes("Y0");
                                y1 = parseFloat(TempY1[0].text);
                                y1 = y1 * vAGridDg * (-1) + vOffset                          
                                vFlag = 0;
                            }
                            
                            else if(m_pntMajor == 1 && m_pntMinor == 17)
                            {
                                rad = vTable1[k].selectNodes("RAD");
                                rad = rad[0].text;
                                rad = 0.006 * vAGridZCD/1.7;
        
                                TempX1 = vTable1[k].selectNodes("X0");
                                x1 = parseFloat(TempX1[0].text);
                                x1 = x1 * vAGridZCD + vOffset;
                            
                                TempY1 = vTable1[k].selectNodes("Y0");
                                y1 = parseFloat(TempY1[0].text);
                                y1 = y1 * vAGridZCD * (-1) + vOffset                          
                                vFlag = 0;
                            }
                            else                            //井型
                            {
                                rad = vTable1[k].selectNodes("RAD");
                                rad = rad[0].text;
                                if (rad == 0)
                                {   
                                    rad = 0.03 * vAGrid/1.7;
                                }
                                else
                                {
                                    rad = rad *vAGrid/1.7;
                                }
                                TempX1 = vTable1[k].selectNodes("X0");
                                x1 = parseFloat(TempX1[0].text);
                                x1 = x1 * vAGrid + vAGrid / 2 + vAGrid + vOffset;
                            
                                TempY1 = vTable1[k].selectNodes("Y0");
                                y1 = parseFloat(TempY1[0].text);
                                y1 = (y1 * vAGrid - vAGrid * 1.5) * (-1) + vOffset;
                                vFlag = 0;
                            }
                        }
                        for (var z = 0; z < DrawDljljd.length; z++)
                        {
                            if (parseInt(vID0[0].text) == DrawDljljd[z])
                            {
                                if (vFlag == 1)
                                {
                                    //往ArrayRemoveByID数组里添加个ID纪录，好让下次擦除
                                    var RemoveID = "Pnt" + vID0[0].text;
                                    ArrayRemoveByID.push(RemoveID);
                                    $("divPntmap").appendChild(MakeADiv("Cir", "Pnt"+vID0[0].text, makeDljljdCirStr("Gk1"+vID0[0].text , 'Red', x0, y0, rad)));
                                }
                                else
                                {
                                    //往ArrayRemoveByID数组里添加个ID纪录，好让下次擦除
                                    var RemoveID = "Pnt" + vID0[0].text;
                                    ArrayRemoveByID.push(RemoveID);
                                    $("divPntmap").appendChild(MakeADiv("Cir", "Pnt"+vID0[0].text, makeDljljdCirStr("Gk1"+vID0[0].text , 'Red', x1, y1, rad)));
                                }
                                //DrawGkong(divPntmap, DrawDljljd[z], TempX0, TempY0, 0.030000, 0, "");
                            }
                        }
                    }
                }
                //往ArrayRemoveByID数组里添加个ID纪录，好让下次擦除
                var RemoveID = "Pnt" + LxID;
                ArrayRemoveByID.push(RemoveID);
                $("divPntmap").appendChild(MakeADiv("Cir", "Pnt"+LxID, makePntLinStr("Gk1"+LxID , 'Red', "0", "0", x0, y0, x1, y1, 1)));
            }
        }
     }//end if (XmlDoc != null)       
}


